; ** por compatibilidad se omiten tildes **
; ==============================================================================
; TRABAJO PRACTICO 3 - System Programming - ORGANIZACION DE COMPUTADOR II - FCEN
; ==============================================================================
; definicion de rutinas de atencion de interrupciones

BITS 32

%include "macrosmodoprotegido.mac"

%define SET_PAGE         286
%define GET_CODE_STACK   386

extern fin_intr_pic1

; macro para definir una rutina de atencion de interrupciones
%macro ISR 1 ;numero de interrupcion
	global _isr%1
	_isr%1:
	LIMPIAR_PANTALLA
	pushfd
	IMPRIMIR_TEXTO msj%1, msj%1_len, 0x0f, 1, 0
	popfd
	ret
%endmacro

; definicion de las rutinas de atencion de interrupciones

msj0: db'Divide Error!'
msj0_len equ $ - msj0

msj1: db'RESERVED'
msj1_len equ $ - msj1

msj2: db'NMI interrupt'
msj2_len equ $ - msj2

msj3: db'Breakpoint'
msj3_len equ $ - msj3

msj4: db'Overflow'
msj4_len equ $ - msj4

msj5: db'BOUND Range Exceeded'
msj5_len equ $ - msj5

msj6: db'Invalid Opcode(Undefined Opcode)'
msj6_len equ $ - msj6

msj7: db'Device Not Available(No Math Coprocessor)'
msj7_len equ $ - msj7

msj8: db'Double Fault'
msj8_len equ $ - msj8

msj9: db'Coprocessor Segment Overrun(reserved)'
msj9_len equ $ - msj9

msj10: db'Invalid TSS'
msj10_len equ $ - msj10

msj11: db'Segment Not Present'
msj11_len equ $ - msj11

msj12: db'Stack-Segment Fault'
msj12_len equ $ - msj12

msj13: db'General Protection'
msj13_len equ $ - msj13

msj14: db'Page Fault'
msj14_len equ $ - msj14

msj15: db'Intel Reserved. Do not use'
msj15_len equ $ - msj15

msj16: db'x87 FPU Floating-Point Error(Math Fault)'
msj16_len equ $ - msj16

msj17: db'Alignment Check'
msj17_len equ $ - msj17

msj18: db'Machine Check'
msj18_len equ $ - msj18

msj19: db'SIMD Floating-Point Exception'
msj19_len equ $ - msj19

msj20: db'Intel Reserved. Do not use'
msj20_len equ $ - msj20

msj21: db'Intel Reserved. Do not use'
msj21_len equ $ - msj21

msj22: db'Intel Reserved. Do not use'
msj22_len equ $ - msj22

msj23: db'Intel Reserved. Do not use'
msj23_len equ $ - msj23

msj24: db'Intel Reserved. Do not use'
msj24_len equ $ - msj24

msj25: db'Intel Reserved. Do not use'
msj25_len equ $ - msj25

msj26: db'Intel Reserved. Do not use'
msj26_len equ $ - msj26

msj27: db'Intel Reserved. Do not use'
msj27_len equ $ - msj27

msj28: db'Intel Reserved. Do not use'
msj28_len equ $ - msj28

msj29: db'Intel Reserved. Do not use'
msj29_len equ $ - msj29

msj30: db'Intel Reserved. Do not use'
msj30_len equ $ - msj30

msj31: db'Intel Reserved. Do not use'
msj31_len equ $ - msj31

; ejercicio 2.a

ISR 0
ISR 1
ISR 2
ISR 3
ISR 4
ISR 5
ISR 6
ISR 7
ISR 8
ISR 9
ISR 10
ISR 11
ISR 12
ISR 13
ISR 14
ISR 15
ISR 16
ISR 17
ISR 18
ISR 19
ISR 20
ISR 21
ISR 22
ISR 23
ISR 24
ISR 25
ISR 26
ISR 27
ISR 28
ISR 29
ISR 30
ISR 31



; rutina de RELOJ

; rutina de TECLADO

; rutina de SERVICIOS

; rutina del reloj
proximo_reloj:
	pushad
	inc DWORD [isrnumero]
	mov ebx, [isrnumero]
	cmp ebx, 0x4
	jl .ok
		mov DWORD [isrnumero], 0x0
		mov ebx, 0
	.ok:
		add ebx, isrClock
		IMPRIMIR_TEXTO ebx, 1, 0x0f, 24, 79
	popad
	ret
	
isrnumero: dd 0x00000000
isrClock:  db '|/-\'


